package model

import "time"

type ShoppingCart struct { //购物车
	BaseModel
	User    int32 `gorm:"type:int;index"` //在购物车列表我们需要查询当前用户的购物车记录
	Goods   int32 `gorm:"type:int;index"` //商品id
	Nums    int32 `gorm:"type:int"`       //商品的数量
	Checked bool  //是否选中

	//没有冗余goodname,goodspice，原因价格一直在变
}

func (ShoppingCart) TableName() string {
	return "shopping_cart"
}

type OrderInfo struct { //订单信息
	BaseModel
	User    int32  `gorm:"type:int;index"`
	OrderSn string `gorm:"type:varchar(30);index comment '订单号'"` //订单号
	PayType string `gorm:"type:varchar(20) comment 'alipay,wechat'"`

	// status大家可以考虑使用iota来做
	Status     string     `gorm:"type:varchar(20) comment 'PAYING(待支付),TRADE_SUCCESS(成功),TRADE_CLOSED(超时关闭), WAIT_BUYER_PAY(交易创建), TRADE_FINISHED(交易结束)'"`
	TradeNo    string     `gorm:"type:varchar(100) comment '交易号'"` // 交易号就是支付宝的订单号，查账
	OrderMount float32    `gorm:"comment '订单价格'"`
	PayTime    *time.Time `gorm:"type:datetime"`

	//订单人信息
	Address      string `gorm:"type:varchar(100) comment '收货地址'"`
	SignerName   string `gorm:"type:varchar(20) comment '收货姓名'"`
	SingerMobile string `gorm:"type:varchar(11) comment '收货电话'"`
	Post         string `gorm:"type:varchar(20) comment '留言'"`
}

func (OrderInfo) TableName() string {
	return "order_info"
}

type OrderGoods struct { //根据订单号查询商品
	BaseModel
	Order int32 `gorm:"type:int;index"` //OrderInfo的id
	Goods int32 `gorm:"type:int;index"`

	//字段冗余
	GoodsName  string `gorm:"type:varchar(100);index"`
	GoodsImage string `gorm:"type:varchar(200)"`
	GoodsPrice float32
	Nums       int32 `gorm:"type:int"`
}

func (OrderGoods) TableName() string {
	return "order_good"
}
